package commons.base.excel.example;

import java.util.ArrayList;
import java.util.List;

import commons.base.excel.ExcelColumnParser;
import commons.base.excel.example.ExcelTestModel.ResourceModel;

public class ResourceModelParser implements ExcelColumnParser {

	@Override
	public Object parse(String columnText) {
		List<ResourceModel> list = new ArrayList<ResourceModel>();
		
		if((columnText == null) || (columnText.trim().length() == 0)){
			return list;
		}
		columnText = columnText.trim();
		
		String[] rs = columnText.split(",");
		for(String reource : rs){
			String[] rr = reource.split("\\|");
			
			ResourceModel model = new ResourceModel();
			model.setType(Integer.parseInt(rr[0]));
			model.setId(Integer.parseInt(rr[1]));
			model.setCount(Integer.parseInt(rr[2]));
			
			list.add(model);
		}
		
		return list;
	}

}
